/**
 * 
 */
package openbang.account.web.portal.widget;

import java.util.List;

import openbang.account.service.entity.UserAccount;
import openbang.account.service.vo.GradeEnum;
import openbang.account.service.vo.PwdVerifyEnum;

import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Widget;

/**
 * @author ibm
 *
 */
public class ViewUserList extends Composite {

	private static TheUiBinder uiBinder = GWT
			.create(TheUiBinder.class);

	interface TheUiBinder extends UiBinder<Widget, ViewUserList> {
	}

	@UiField 
	Grid userGrid;
	
	public ViewUserList() {
		initWidget(uiBinder.createAndBindUi(this));
		//   <TR><TH>帐号</TH><TH>姓名</TH><TH>昵称</TH><TH>注册日期</TH></TR>
		//   <TR><TD></TD>    <TD></TD>     <TD></TD>    <TD></TD></TR>
	}


	public void initData(List<UserAccount> users) {
		userGrid.setStyleName("memberListTable");//这里设置css memberListTable在IE里没有效果
		userGrid.resize(users.size()+1,4);
		userGrid.setHTML(0,0,"<div class=\"memberListTable\"><center><b>昵称</b></center></div>");
		userGrid.setHTML(0,1,"<div class=\"memberListTable\"><center><b>会员类型</b></center></div>");
		userGrid.setHTML(0,2,"<div class=\"memberListTable\"><center><b>密码管理方式</b></center></div>");
		userGrid.setHTML(0,3,"<div class=\"memberListTable\"><center><b>注册日期</b></center></div>");
		int row = 1; //从起始位1开始
		for(UserAccount user : users){
			userGrid.setHTML(row, 0,"<div class=\"memberListTable\">"+user.getNiceName()+"</div>");
			userGrid.setHTML(row, 1,"<div class=\"memberListTable\">"+ GradeEnum.getDesc(user.getGrade()) +"</div>");
			userGrid.setHTML(row, 2,"<div class=\"memberListTable\">"+ PwdVerifyEnum.getDesc(user.getVerifyType()) +"</div>");
			userGrid.setHTML(row, 3,"<div class=\"memberListTable\">"+ DateTimeFormat.getFormat("yyyy-MM-dd HH:mm").format(user.getRegTime())+"</div>");
			row++;
		}
	}

}
